<template>
  <div>
    <el-form
        label-width="100px"
        style="max-width: 460px">
      <el-form-item label="姓名">
        <el-input v-model="form.name" clearable/>
      </el-form-item>
      <el-form-item label="天数">
        <el-input v-model="form.day" clearable/>
      </el-form-item>
      <el-form-item label="原因">
        <el-input v-model="form.reason" clearable/>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="submit()">提交</el-button>
        <el-button @click="back()">取消</el-button>
      </el-form-item>
    </el-form>
  </div>

</template>

<script>

import router from "@/router";

export default {
  name: 'LeaveName',
  data() {
    return {
      form: {
        staffId: '1',
        name: '成功',
        day: '3',
        reason: 'fgg'
      },
    };
  },
  methods: {
    submit() {
      console.log(this.form)
      this.axios.post("http://172.20.10.3:8080/startLeaveProcess", this.form).then(res => {
        if (res.status === 200) {
          console.log(res.data)
          this.$message({
            message: "流程提交成功",
            type: 'success',
          })
          router.push({
            name: 'ListName',
          })
        } else {
          this.$message({
            message: "流程提交失败",
            type: 'error',
          })
        }
      }).catch(() => {
        this.$message({
          message: "网络错误",
          type: 'error',
        })
      })
    },
    back() {
      router.push("/")
    }
  }
}
</script>
